package exception;

public class TryCatchDemo2 {
    public static void main(String[] args) {
        System.out.println("程序开始了");

        try {
            String str = "hello";
            String str1 = null;
            System.out.println(str1.length());
            System.out.println(str.charAt(5));

        } catch (NullPointerException e) {
            System.out.println("空指针异常");
        } catch (Exception e) {
            System.out.println("异常");
        }

        System.out.println("程序结束了");
    }
}
